package demo15;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerTest3 {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket=new ServerSocket(5000);
            Socket socket=serverSocket.accept();
            InputStream is=socket.getInputStream();
            ObjectInputStream ois=new ObjectInputStream(is);
            User user=(User)ois.readObject();
            OutputStream os=socket.getOutputStream();
            if(!user.getUserName().equals("bjsxt")||!user.getPassWord().equals("bjsxt")){
                    String replay1="登陆失败";
                    os.write(replay1.getBytes());
            }
            if(user.getUserName().equals("bjsxt")||user.getPassWord().equals("bjsxt")){
                    String replay2="登陆成功";
                    os.write(replay2.getBytes());
            }
            serverSocket.close();
            socket.close();
            is.close();
            ois.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
